package com.ouc.dataMange.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ouc.common.annotation.Log;
import com.ouc.common.core.controller.BaseController;
import com.ouc.common.core.domain.AjaxResult;
import com.ouc.common.enums.BusinessType;
import com.ouc.dataMange.domain.SysMysqlBackup;
import com.ouc.dataMange.service.ISysMysqlBackupService;
import com.ouc.common.utils.poi.ExcelUtil;
import com.ouc.common.core.page.TableDataInfo;

/**
 * mysqlBackupController
 * 
 * @author ouc
 * @date 2025-07-25
 */
@RestController
@RequestMapping("/dataMange/mysqlBackup")
public class SysMysqlBackupController extends BaseController
{
    @Autowired
    private ISysMysqlBackupService sysMysqlBackupService;

    /**
     * 查询mysqlBackup列表
     */
//    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMysqlBackup sysMysqlBackup)
    {
        startPage();
        List<SysMysqlBackup> list = sysMysqlBackupService.selectSysMysqlBackupList(sysMysqlBackup);
        return getDataTable(list);
    }

    /**
     * 导出mysqlBackup列表
     */
    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:export')")
    @Log(title = "mysqlBackup", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysMysqlBackup sysMysqlBackup)
    {
        List<SysMysqlBackup> list = sysMysqlBackupService.selectSysMysqlBackupList(sysMysqlBackup);
        ExcelUtil<SysMysqlBackup> util = new ExcelUtil<SysMysqlBackup>(SysMysqlBackup.class);
        util.exportExcel(response, list, "mysqlBackup数据");
    }

    /**
     * 获取mysqlBackup详细信息
     */
    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:query')")
    @GetMapping(value = "/{backupId}")
    public AjaxResult getInfo(@PathVariable("backupId") Integer backupId)
    {
        return success(sysMysqlBackupService.selectSysMysqlBackupByBackupId(backupId));
    }

    /**
     * 新增mysqlBackup
     */
    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:add')")
    @Log(title = "mysqlBackup", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysMysqlBackup sysMysqlBackup)
    {
        return toAjax(sysMysqlBackupService.insertSysMysqlBackup(sysMysqlBackup));
    }

    /**
     * 修改mysqlBackup
     */
    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:edit')")
    @Log(title = "mysqlBackup", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysMysqlBackup sysMysqlBackup)
    {
        return toAjax(sysMysqlBackupService.updateSysMysqlBackup(sysMysqlBackup));
    }

    /**
     * 删除mysqlBackup
     */
    @PreAuthorize("@ss.hasPermi('dataMange:mysqlBackup:remove')")
    @Log(title = "mysqlBackup", businessType = BusinessType.DELETE)
	@DeleteMapping("/{backupIds}")
    public AjaxResult remove(@PathVariable Integer[] backupIds)
    {
        return toAjax(sysMysqlBackupService.deleteSysMysqlBackupByBackupIds(backupIds));
    }
}
